#  Copyright (c) 2020 - ~, WANGXI
#  
#  GRAMMA UNINTEST LOSS AWK FILE
#  Used in NS-2 simulator
#  Clone from https://gitee.com/WangXi_Chn/ns2_modulelib
#  Note in https://www.yuque.com/wangxi_chn/kozrfl
#  
#  Change Logs:
#  Date           Author       Notes			Mail
#  2020-11-24     WangXi   	   first version	WangXi_Chn@foxmail.com

# calculate the num of loss-packet-rate on trace node_1 to node_3

BEGIN {
    num_pkts_sent = 0;
    num_pkts_rcvd = 0;
}

{
    action = $1;
    time = $2;
    from = $3;
    to = $4;
    type = $5;
    pktsize_ = $6;
    flow_id = $8;
    src = $9;
    dst = $10;
    seq_no = $11;
    packet_id = $12;

    if(from == "1" && action == "+" && flow_id == "2"){
        num_pkts_sent++;
    }
    if(to == "3" && flow_id == "2" && action == "r"){
        num_pkts_rcvd++;
    }
}

END {
    printf("number of packets sent: %d lost: %d\n",num_pkts_sent,num_pkts_sent-num_pkts_rcvd);
}

#/************************ (C) COPYRIGHT 2020 WANGXI **************END OF FILE****/
